package com.bcxj.serviceprice.controller;

import com.bcxj.internalcommon.dto.ForecastPriceDTO;
import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.response.ForecastPriceResponse;
import com.bcxj.serviceprice.service.ForecastPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: ForecastPriceController
 * Package: com.bcxj.serviceprice.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/10/5 15:00
 * @Version 1.0
 * @Since 1.0
 */
@RestController
public class ForecastPriceController {

    @Autowired
    private ForecastPriceService forecastPriceService;


    /**
     * 预估价格
     * @param forecastPriceDTO
     * @return
     */
    @PostMapping("/forecast-price")
    public ResponseResult forecastPrice(@RequestBody ForecastPriceDTO forecastPriceDTO) {
        String depLongitude = forecastPriceDTO.getDepLongitude();
        String depLatitude = forecastPriceDTO.getDepLatitude();
        String destLongitude = forecastPriceDTO.getDestLongitude();
        String destLatitude = forecastPriceDTO.getDestLatitude();
        String cityCode = forecastPriceDTO.getCityCode();
        String vehicleType = forecastPriceDTO.getVehicleType();
        return forecastPriceService.forecastPrice(
                depLongitude, depLatitude, destLongitude, destLatitude, cityCode, vehicleType);
    }

    /**
     * 计算真实价格
     * @param distance
     * @param duration
     * @param fareType
     * @param fareVersion
     * @return
     */
    @PostMapping("calculate-price")
    public ResponseResult<Double> calculatePrice(@RequestParam String distance,
                                                 @RequestParam String duration,
                                                 @RequestParam String fareType,
                                                 @RequestParam String fareVersion) {
        return forecastPriceService.calculatePrice(distance, duration, fareType, fareVersion);
    }

}
